﻿using System;

class Program
{
    static void Main(string[] args)
    {
        Console.Write("请输入数组的长度：");
        int length = Convert.ToInt32(Console.ReadLine());
        int[] numbers = new int[length];

        Console.WriteLine($"请输入 {length} 个整数：");
        for (int i = 0; i < length; i++)
        {
            Console.Write($"数组元素 {i + 1}: ");
            numbers[i] = Convert.ToInt32(Console.ReadLine());
        }

        int max = numbers[0];
        int min = numbers[0];
        long sum = 0; // 使用 long 以防溢出

        foreach (int number in numbers)
        {
            if (number > max)
            {
                max = number;
            }
            if (number < min)
            {
                min = number;
            }
            sum += number;
        }

        double average = sum / (double)length; // 使用 double 计算平均值

        Console.WriteLine($"最大值: {max}");
        Console.WriteLine($"最小值: {min}");
        Console.WriteLine($"平均值: {average}");
        Console.WriteLine($"所有元素的和: {sum}");
    }
}


























